package com.huawei.esdk.tp.device.smc.v100r003c10;

import com.huawei.esdk.platform.common.SDKErrorCode;
import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.commu.itf.ICXFSOAPProtocolAdapter;
import com.huawei.esdk.platform.exception.ProtocolAdapterException;
import com.huawei.esdk.tp.device.smc.v100r003c00.SMC20V1R3C00ConferenceControlCapabilityImpl;
import com.huawei.esdk.tp.domain.model.ScheduleConference;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.CancelChairman;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.CancelChairmanResponse;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.ConferenceId;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.LockPresentation;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.LockPresentationResponse;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.SetChairman;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.SetChairmanResponse;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.SmcExternal2Soap;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.UnlockPresentation;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r003c10.UnlockPresentationResponse;

/**
 * 会议控制能力类
 * <p>
 * 适配SMC2.0 V1R3C00版本新接口
 * <p>
 * @author  cWX191990
 * @see  [相关类/方法]
 * @since  [eSDK TP V100R003C20]
 */
public class SMC20V1R3C10ConferenceControlCapabilityImpl extends SMC20V1R3C00ConferenceControlCapabilityImpl implements
    SMC20V1R3C10IConferenceControlCapability
{
    
    public SMC20V1R3C10ConferenceControlCapabilityImpl(ICXFSOAPProtocolAdapter cxfSOAPProtocolAdapter)
    {
        super(cxfSOAPProtocolAdapter);
    }
    
    protected String getR3C10SouthItfName()
    {
        return SmcExternal2Soap.class.getName();
    }
    
    @Override
    public SDKErrorCode unlockPresentation(String id)
    {
        SDKResult<ScheduleConference> result = new SDKResult<ScheduleConference>();
        UnlockPresentationResponse responseSouth = null;
        try
        {
            UnlockPresentation resMsg = new UnlockPresentation();
            ConferenceId confid = new ConferenceId();
            confid.setConfInternalId(Long.parseLong(id));
            resMsg.setConfId(confid);
            
            responseSouth =
                (UnlockPresentationResponse)sendProtocolMessage(resMsg, getR3C10SouthItfName(), "unlockPresentation");
            result.setErrCode(responseSouth.getUnlockPresentationResult().getErrCode());
        }
        catch (ProtocolAdapterException e)
        {
            result.setErrCode(e.getErrorCode());
            return result;
        }
        
        return result;
    }
    
    @Override
    public SDKErrorCode lockPresentation(String id, String siteUri)
    {
        SDKErrorCode result = new SDKErrorCode();
        LockPresentationResponse responseSouth = null;
        try
        {
            LockPresentation resMsg = new LockPresentation();
            ConferenceId confid = new ConferenceId();
            confid.setConfInternalId(Long.parseLong(id));
            resMsg.setConfId(confid);
            resMsg.setSiteUri(siteUri);
            
            responseSouth =
                (LockPresentationResponse)sendProtocolMessage(resMsg, getR3C10SouthItfName(), "lockPresentation");
            result.setErrCode(responseSouth.getLockPresentationResult().getErrCode());
        }
        catch (ProtocolAdapterException e)
        {
            result.setErrCode(e.getErrorCode());
            return result;
        }
        
        return result;
    }
    
    @Override
    public SDKErrorCode requestConfChairEx(String confId, String chairmanUri)
    {
        SDKErrorCode result = new SDKErrorCode();
        SetChairman resMsg = new SetChairman();
        
        ConferenceId conferenceId = new ConferenceId();
        conferenceId.setConfInternalId(Long.parseLong(confId));
        resMsg.setConfId(conferenceId);
        resMsg.setChairmanUri(chairmanUri);
        
        SetChairmanResponse response = null;
        
        try
        {
            response = (SetChairmanResponse)sendProtocolMessage(resMsg, getR3C10SouthItfName(), "setChairman");
            result.setErrCode(response.getSetChairmanResult().getErrCode());
        }
        catch (ProtocolAdapterException e)
        {
            result.setErrCode(e.getErrorCode());
            return result;
        }
        
        return result;
    }
    
    @Override
    public SDKErrorCode releaseConfChairEx(String confId)
    {
        SDKErrorCode result = new SDKErrorCode();
        CancelChairman resMsg = new CancelChairman();
        ConferenceId conferenceId = new ConferenceId();
        conferenceId.setConfInternalId(Long.parseLong(confId));
        resMsg.setConfId(conferenceId);
        
        CancelChairmanResponse response = null;
        
        try
        {
            response = (CancelChairmanResponse)sendProtocolMessage(resMsg, getR3C10SouthItfName(), "cancelChairman");
            result.setErrCode(response.getCancelChairmanResult().getErrCode());
        }
        catch (ProtocolAdapterException e)
        {
            result.setErrCode(e.getErrorCode());
            return result;
        }
        
        return result;
    }
    
}
